package day0401;

import java.util.Scanner;

public class MaxNumString2 {
    /**
     * 2.最大数字字符串(选择排序)
     * 小组中每位都有一张卡片，卡片是6位以内的正整数，将卡片连起来可以组成多种数字，计算组成的最大数字
     * 输入
     * 22,221
     * 输出
     * 22221
     * 示例二
     * 输入
     * 4589,101,41425,9999
     * 输出
     * 9999458941425101
     */
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] num = sc.nextLine().split(",");
        sc.close();
        for (int i = 0; i < num.length - 1; i++) {
            for (int j = i + 1; j < num.length; j++) {
                if (Integer.parseInt(num[i] + num[j]) < Integer.parseInt(num[j] + num[i])) {
                    String temp = num[i];
                    num[i] = num[j];
                    num[j] = temp;
                }
            }
        }
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < num.length; i++) {
            sb.append(num[i]);
        }
        System.out.println(sb);

    }
}
